package org.servlet;

import com.github.wxpay.sdk.Order;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class PayoverServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String url = (String)session.getAttribute("Payover");
        Order order = new Order();
        if(order.getStatus(url)==false)
        {
            request.setAttribute("msg", "Pay Unsuccessfully!");
            request.setAttribute("error1", "You've failed in paying it!");
            request.getRequestDispatcher("showPay").forward(request,response);
        }
        else
        {
            request.getRequestDispatcher("confirmOrder").forward(request,response);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
